<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<%
String dirId = request.getParameter("dirId");
%>
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
		<title>联系人上传</title>
		<meta name="Robots" content="all" />
		<meta name="Author" content="Gushu">
		<meta name="Description" content="" />
		<meta name="Keywords" content="" />
		<link rel="shortcut icon" href="/favicon.ico" />
		<link rel="home" href="" />
		<link rel="stylesheet" href="../styles/style.css" type="text/css" /> 
		<script src="../scripts/jquery.js" type="text/javascript" charset="utf-8"></script>
		<script src="../scripts/tabs.js" type="text/javascript" charset="utf-8"></script>
		<script src="../scripts/dragndrop.js" type="text/javascript" charset="utf-8"></script>
		<script src="../scripts/msgbox.js" type="text/javascript" charset="utf-8"></script>
		<script type="text/javascript" src="../scripts/jquery.poshytip.js"></script>
		<script language="javascript" type="text/javascript" src="../scripts/treeview.js"></script>
		<script language="javascript" type="text/javascript" src="../scripts/mainAddress.js"></script>
		<script type="text/javascript">
  var updater = null;

  function startStatusCheck()
  {
    //设置上传按钮为不可用状态，避免多次提交
    $('submitButton').disabled = true;
    //创建周期性发送请求的Ajax对象
    updater = new Ajax.PeriodicalUpdater(
                                'status',
                                'MmsSendServlet',
                                {asynchronous:true, frequency:1, method: 'get', parameters: 'c=status', onFailure: reportError});

    return true;
  }
//出错时处理方法
  function reportError(request)
  {
    $('submitButton').disabled = false;

    $('status').innerHTML = '<div class="error"><b>Error communicating with server. Please try again.</b></div>';
  }
//上传完毕后,取消周期性获取进度状态，将最终的状态显示在客户端
  function killUpdate(message)
  {
    $('submitButton').disabled = false;
    //停止刷新获取进度
    
    updater.stop();
    if(message != '')//如果有错误信息，则显示出来
    {
      $('status').innerHTML = '<div class="error"><b>Error processing results: ' + message + '</b></div>';
    }
    else//如果没有错误信息
    {
      //获取上传文件的完成状态，显示到客户端
      new Ajax.Updater('status',
                     'UpLoadServlet',
                     {asynchronous:true, method: 'get', parameters: 'c=status', onFailure: reportError});
    }
  }
  </script>
		<script type="text/javascript">
  	function importContact(){
  		//var fileName = document.getElementById("importFile").value;
  		var fileName = document.getElementById("file").value;
  		//return false;
		var lastFileName = encodeURI(fileName);
 		lastFileName = encodeURI(lastFileName);
 		 var file_Name = fileName.split(".")[fileName.split(".").length-1];
			if(file_Name=="xls"||file_Name=="XLS")
  			 {
			 
			 }else
			 {
			 	alert("上传文件格式不对，请重新导入！");
			 	return ;
			 }
			fileform.action="./AddressServlet?method=importContactSubmit&dirId=<%=dirId%>&realImagePath="+lastFileName;
			fileform.submit();
			eval("top.fileform.mb.close()");
  	}
	</script>
	</head>
	<body>

		<!-- 这个是隐藏的<ifame>作为表单提交后处理的后台目标-->
		
		<section id="container">
		    <div id="main">
			<div class="tabs">
                <ul class="tabs-nav clearfix">
                	<li>上传联系人</li>
                </ul>
		
		<div id="div2" class="tabs-panel">
			<!-- 当表单提交后,调用startStatusCheck()方法-->
			<form enctype="multipart/form-data" name="fileform" method="post" id="fileform"
				action="./AddressServlet?method=importContactSubmit"
				onsubmit="return startStatusCheck();">
				<table width="100%" border="0" align="center" cellpadding="0"
					cellspacing="0">
					<tr>
					<td class="tc">模版格式：</td> 
					<td  align="left">
					<a href="./module/date.xls" >点击这里下载导入模板</a>
					</td></tr>
								<tr>
									<td class="tc" width="18%" align="right" valign="middle">
										文件：
									</td>
									<td align="left">
										<input type="file" id="file" name="file" >
									</td>
								</tr>
								<tr><td class="tc" colspan="2"><input type="button" value="确定" onclick="importContact();"/> 
                              <input type="button" value="关闭" onclick="$mb.close();"/>
                              <input type="hidden" name="dirId" id="dirId" value="<%=dirId %>"/>
                              </td>
					</tr>
				</table>
			</form>
		</div>
</div>
</div>
</section>
	</body>
</html>
